package com.mybatis.mapper;

import java.util.List;

import com.mybatis.anno.Delete;
import com.mybatis.anno.Insert;
import com.mybatis.anno.Mapper;
import com.mybatis.anno.Result;
import com.mybatis.anno.ResultMap;
import com.mybatis.anno.ResultMapStruct;
import com.mybatis.anno.ResultMapStructLists;
import com.mybatis.anno.Select;
import com.mybatis.anno.Update;
import com.mybatis.po.User;
@Mapper
@ResultMapStructLists({@ResultMapStruct(id = "userMap",value = {
        @Result(id=true,column = "id",property = "id"),
        @Result(column = "name",property = "name"),
        @Result(column = "password",property = "password")
}),@ResultMapStruct(id = "userMap1",value = {
        @Result(id=true,column = "id",property = "id"),
        @Result(column = "password",property = "password")
})})
public interface UserMapper {

	@Insert("insert into user(name,password)values(#{name},#{password})")
	public int save(User user);
	
	@Update("update user set name=#{name},password=#{password} where id=#{id}")
	public int update(User user);
	
	@Delete("delete from user where id=#{id}")
	public int delete(User user);
	
	@Select("select * from user where id=#{id}")
	@ResultMap("userMap")
	public User selectById(User user);
	
	@Select("select * from user")
	@ResultMap("userMap")
	List<User> findAll();
	
	@Select("select * from user")
	@ResultMap("userMap1")
	List<User> findAll2();
}
